import java.util.Scanner;

//思想：比较原来牌的下标i与n的大小
//下标比n小时重洗后该牌的下标变为2*i,下标大于等于n时重洗后牌的下标为2*(i-n)+1

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        while (m>0){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int array[] = new int[2*n];

            for(int i = 0;i<array.length;i++){
                int temp = i;
                for(int j= 0;j<k;j++){
                    if(temp<n){
                        temp = 2*temp;
                    }else{
                        temp = 2*(temp-n)+1;
                    }
                }
                array[temp] = sc.nextInt();
            }
            //输出重洗后的扑克牌
            for(int i = 0;i<array.length;i++){
                if(i == array.length-1){
                    System.out.print(array[i]);
                }else{
                    System.out.print(array[i]+" ");
                }
            }
            System.out.println();
            m--;
        }
    }
}

